package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.data.entity.BusinessModelField;
import com.nbsaas.boot.project.api.domain.response.BusinessModelFieldResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;
/**
* 实体对象转化成响应对象
*/

public class BusinessModelFieldResponseConvert  implements Converter<BusinessModelFieldResponse,BusinessModelField> {

    @Override
    public BusinessModelFieldResponse convert(BusinessModelField source) {
        BusinessModelFieldResponse  result = new  BusinessModelFieldResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getDataType()!=null){
                        result.setDataTypeName(source.getDataType().getName());
                    }
                    if(source.getBusinessModel()!=null){
                        result.setBusinessModel(source.getBusinessModel().getId());
                    }
                    if(source.getDataType()!=null){
                        result.setDataType(source.getDataType().getId());
                    }
                    if(source.getShowType()!=null){
                    Map<Integer,String> ShowTypeMap=new HashMap<>();
                        ShowTypeMap.put(1,"显示");
                        ShowTypeMap.put(2,"不显示");
                    String label=  ShowTypeMap.get(source.getShowType());
                    result.setShowTypeName(label);
                    }
                    result.setShowType(source.getShowType());
                    if(source.getBusinessModel()!=null){
                        result.setBusinessModelName(source.getBusinessModel().getName());
                    }
        return result;
    }

}

